package com.ljdy.product.exception;

import java.util.HashMap;
import java.util.Map;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@ResponseBody
public class GlobalExceptionHandler {

	@ExceptionHandler(Exception.class)
	public Map<String,Object> exceptionHadler(Exception ex) {
		
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("code", "100");
		map.put("msg", ex.getMessage());
		return map;
	}
	
	@ExceptionHandler(NotIsPictureException.class)
	public Map<String,Object> exceptionHadler(NotIsPictureException ex) {
		
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("code", ex.getCode());
		map.put("msg", ex.getMessage());
		return map;
	}
}
